home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 3498 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.3 KB  |  30 lines

  1. Newsgroups: comp.lang.c
  2. Path: mxsld2.pd.infn.it!LORETI
  3. From: loreti@mxsld2.pd.infn.it (Maurizio Loreti)
  4. Subject: Re: Finding a prime number
  5. X-Nntp-Posting-Host: mxsld2.pd.infn.it
  6. Message-ID: <DLy7y5.B0z@news.cern.ch>
  7. Sender: news@news.cern.ch (USENET News System)
  8. Reply-To: loreti@mxsld2.pd.infn.it
  9. Organization: I.N.F.N. Padova - CDF/CMS VAXcluster
  10. References: <4e875s$nqk@reader2.ix.netcom.com>,<4eb8lo$9rf@news1.cle.ab.com>
  11. Distribution: inet
  12. Date: Mon, 29 Jan 1996 15:20:26 GMT
  13.  
  14. In article <4eb8lo$9rf@news1.cle.ab.com>, don.phillips@ab.com (Donald-Anthony C. Phillips) writes:
  15. >    It seems your algorithm may not be mathematically correct.  Your
  16. >assumption( if i'm reading your code right) is that if a number is not
  17. >divisible evenly by any of the numbers 0-9, then it must be prime.
  18. >This is not correct. 
  19. >    Take for instance the number 247.  It is not divisible by 0-9 but it
  20. >is not a prime number( 13*19 = 247).  The definition of a prime number
  21. >is a number divisible only by one and the number.
  22. >    Most prime number algorithms will be iterative or recursive by nature.
  23. >A number (n)  is prime if is not divisible by any number from 2 thru
  24. >(n - 1).....roughly.
  25.  
  26. You misspelled floor(sqrt(n)).
  27. --
  28. Maurizio Loreti                       http://mvxpd5.pd.infn.it/wwwcdf/mlo.html
  29. Un. of Padova, Dept. of Physics - Padova, Italy          loreti@padova.infn.it
  30.